#Help with a bug

1 messages · Page 1 of 1 (latest)

pearl sundial
#

This is the purchasing script for my game:

local ServerStorage = game:GetService("ServerStorage")
local Tool = ServerStorage.Tools:FindFirstChild("FullMutatedSolarEclipse")

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
local leaderstats = player:FindFirstChild("leaderstats")
local Cash = leaderstats and leaderstats:FindFirstChild("Orbs")

if Cash and Cash.Value >= 20000 then
    Cash.Value -= 20000
    local ClonedTool = Tool:Clone()
    task.wait(0.1)
    local backpack = player:WaitForChild("Backpack")
    ClonedTool.Parent = backpack
    script.Parent:Destroy()
    game.Workspace.Sounds.POP.Playing = true
end

end)

but sometimes when the player equips the tool, it gets deleted after the player has held it for a little (the tools dont have any scripts) and it is prob from this script.
Any ideas why?

graceful cradle
#

Lemme see...

#

When you create the new tool, does it use this same script?

pearl sundial
#

@graceful cradle alright so like i have tools in serverstorage

#

no scripts in them

#

it just clones it from serverstorage

#

and i have multiple of these scripts for every tool

#

the scripts parent is a model

#

that looks like the tool

#

to give the effect that you are buying it from the tool itself

#

for addtional info i clone the models from replicatedstorage and then you can press e to buy the tool

graceful cradle
#

Look...
The only ways for the tool to get destroyed is...
:Destroy()
.Parent = nil or something not in the backpack

#

But to make sure
Your tools are anchored right?

pearl sundial
#

they use welds

graceful cradle
#

So they don't fall out of the map right??

pearl sundial
#

no they just get destroyed

#

here is the typical tool setup

graceful cradle
#

Where was the script parented anyways? Cause the script could possibly destroy the tool..

pearl sundial
#

its in a model

#

the shouldnt be related at all

#

they

#

ok so my game has a slide that spawns planet models and they roll down you can press e to buy a tool version of the planet

#

the tools dont have scripts cause the models dont equal tools

#

they are dif things

graceful cradle
#

No, it may be, cause if somehow the tool gets parented to that model and that model gets deleted, the tool will also get deleted, but the model is in workspace right? So there is no problem

pearl sundial
#

that look the same

true radishBOT
#

studio** You are now Level 6! **studio

pearl sundial
#

but it doesnt delete it instantly

#

after the model gets deleted

#

from buying

#

and sometimes the tool doesnt even get deleted

graceful cradle
pearl sundial
#

local Prox = script.Parent

local itemValues = {
Mercury = 200,
Mars = 500,
Venus = 1000,
Earth = 2000,
Neptune = 3000,
Uranus = 5000,
Saturn = 6000,
Jupiter = 7000,
Sun = 10000,
Moon = 14000,
BloodMoon = 20000,
BlueMoon = 30000,
SolarEclipse = 40000,
FullMutatedSolarEclipse = 80000,
}

Prox.Triggered:Connect(function(Player)
local leaderstats = Player:FindFirstChild("leaderstats")
local Orbs = leaderstats and leaderstats:FindFirstChild("Orbs")
if not leaderstats or not Orbs then
warn("Missing leaderstats or Orbs for player: " .. Player.Name)
return
end

local character = Player.Character
if not character then return end


for _, item in pairs(character:GetChildren()) do
    if item:IsA("Tool") and itemValues[item.Name] then
        Orbs.Value = Orbs.Value + itemValues[item.Name]
        item:Destroy()
        Player.leaderstats.SoldPlanets.Value = Player.leaderstats.SoldPlanets.Value + 1
        break 
    end
end

end)

#

heres a selling script

#

i deleted it once and it still got deleted

#

but

#

this is the only other thing that destroys tools

graceful cradle
#

Also all of the scripts are server-sided right?

#

Just asking

pearl sundial
#

yup

#

if script.Parent.Parent == game.Workspace then
task.wait(120)
script.Parent:Destroy()
end
the models also have this

#

to yk not fill the map

#

but i dont think this would cause anything

graceful cradle
pearl sundial
#

when the sell proxmityprompt is activated

graceful cradle
#

Is it fired to update the player's score and that's it?

pearl sundial
#

yes

graceful cradle
pearl sundial
#

and destroy the sold tool

graceful cradle
#

It has item:Dstory

pearl sundial
#

yea it should do that

#

to yk sell the item

#

it SHOULD be destroyed when the player sells the tool

umbral vector
true radishBOT
#

studio** You are now Level 9! **studio

pearl sundial
umbral vector
#

Ok ok.🥀🥀

pearl sundial
graceful cradle
pearl sundial
#

how would it randomly fire tho?

#

the player isnt even close to the sell thing

graceful cradle
#

Idk, sometimes even my own code does stuff I didn't know about,

#

Look

#

Add a print(1111) at the start of the function

#

And run the game

pearl sundial
#

alright

graceful cradle
#

Basically if you sell an item

#

It will show the message

#

But if you hold an item without selling and it shows, there is a problem

#

Basically check...
If your item gets destroyed and that message appears

pearl sundial
#

actually no this isnt the problem cause when the tool gets deleted you dont get the orbs

graceful cradle
#

200% that's the problem

pearl sundial
#

and i even have a pop up for when you get money

graceful cradle
#

Oh ok

graceful cradle
#

There is another non-code problem

#

Does your tool use handles?

pearl sundial
#

yup

graceful cradle
#

If you use handles incorrectly it can vanish randomly

pearl sundial
#

what would be an incorrect use

#

i have welded the model and the handle tghter

graceful cradle
#

Let's go through a list...

#

Do you change the handle name mid game using code?

pearl sundial
#

no

graceful cradle
#

Kk..

#

Is handler.CanCollide = false??

#

Physics problems can cause offsets and Roblox just counts the tool broken and deletes it

pearl sundial
#

yes

#

wait

#

no but

#

the model is

#

@graceful cradle yo quick info if i give the tool with admin it doesnt get deleted

graceful cradle
pearl sundial
#

yea

#

im a new scripter so maybe my purchasing script just sucks

#

i really wanna fix this cuz my game has potential

#

it has reached the algorythm kind of

#

i have had 4 random players in it

#

before i closed it due to this bug

#

@graceful cradle so i know you prob wont care that much and your gonna quit like the others

#

this bug is actually so odd

graceful cradle
pearl sundial
#

and thanks

graceful cradle
#

yw, but what is the bug? Is it that tool bug always vanishes?

pearl sundial
#

okay so lets say the player buys the "planet" and he gets it but lets wait a few secs and it just vansishes

#

now

#

it doesnt always happen

#

but

#

it can happen

graceful cradle
#

Also did you test that print(1111)
When holding an item?

pearl sundial
#

and i cant have players loosing their good items

graceful cradle
# pearl sundial huh? why?

Maybe the problem was there all along, it's better to check every system that is changing the player's tools

pearl sundial
graceful cradle
pearl sundial
#

but im positive its the purchasing

graceful cradle
pearl sundial
#

but like nothing deletes the tools

#

only models

#

expect the selling but thats not it prob

graceful cradle
#
Prox.Triggered:Connect(function(Player)
    local leaderstats = Player:FindFirstChild("leaderstats")
    local Orbs = leaderstats and leaderstats:FindFirstChild("Orbs")
    if not leaderstats or not Orbs then
        warn("Missing leaderstats or Orbs for player: " .. Player.Name)
        return
    end

    local character = Player.Character
    if not character then return end


    for _, item in pairs(character:GetChildren()) do
        if item:IsA("Tool") and itemValues[item.Name] then
            Orbs.Value = Orbs.Value + itemValues[item.Name]
            item:Destroy()
            Player.leaderstats.SoldPlanets.Value = Player.leaderstats.SoldPlanets.Value + 1
            break 
        end
    end
end```
#

Here is the item: Desroy()

#

Replace it with
item:Destroy(); print(1111)

#

Maybe the problem was there all along maybe

pearl sundial
#

local Prox = script.Parent

local itemValues = {
Mercury = 200,
Mars = 500,
Venus = 1000,
Earth = 2000,
Neptune = 3000,
Uranus = 5000,
Saturn = 6000,
Jupiter = 7000,
Sun = 10000,
Moon = 14000,
BloodMoon = 20000,
BlueMoon = 30000,
SolarEclipse = 40000,
FullMutatedSolarEclipse = 80000,
}

local Cash = game.Workspace.Sounds.CashSound

Prox.Triggered:Connect(function(Player)
print("item sold")
local leaderstats = Player:FindFirstChild("leaderstats")
local Orbs = leaderstats and leaderstats:FindFirstChild("Orbs")
if not leaderstats or not Orbs then
warn("Missing leaderstats or Orbs for player: " .. Player.Name)
return
end

local items = {Player.Backpack, Player.Character}
for _, items in pairs(items) do
    for _, item in pairs(items:GetChildren()) do
        if itemValues[item.Name] then
            Orbs.Value = Orbs.Value + itemValues[item.Name]
            item:Destroy();  print(1111)

end
end
end
end)
also to add i have a sell all thing too

graceful cradle
#

Kk,

#

Look if you get 1111 and your tool gets deleted at the same time

#

That code is the problem

pearl sundial
#

@graceful cradle okay so i might be delulu

#

but i had speed thingys in my game

#

(tools)

#

that got destroyed and they give speed

#

i have removed them some time ago

#

and now the planets dont get deleted

#

after i have been testing for some time now

#

i dont think those could have been the problem tho

graceful cradle
#

So is there any solution for that bug then?

pearl sundial
#

huh?

#

im not sure but i think i solved it

graceful cradle
pearl sundial
#

cause they havent been deleted after i removed my speedboosts

pearl sundial
#

cause if a tool has a script that destroys it

#

could it affect other tools?

#

due to lag or other things?

graceful cradle
#

Well, maybe yes in specific cases

pearl sundial
#

wish me luck

#

if the bug still happens im going to get deperresd at this rate

#

i know it sounds silly

#

but

#

i have scrapped so many projects

#

and this is the one that is so close to being finished

#

and i get let a dumb bug scrap this too

graceful cradle
#

Also what is your game about?

pearl sundial
#

alright so this is a simpe game cause im not a advanced scripter but

#

there is a big slide in the map

#

that has planets rolling down it

#

and you can buy then and sell them

#

its like a shitty rng

#

now i trust you enough that you wont steal my idea

#

even tho it prob isnt good

#

but cant risk nun

#

@graceful cradle hey?

graceful cradle
#

Is it open? I'd like to play honestly, I know you closed it but the bug is gone right?

#

Lemme play test it if you want

graceful cradle
pearl sundial
#

@graceful cradle please note this game isnt meant to be public

#

its wip

#

and report if any bugs happen pelase

graceful cradle
#

Kk

pearl sundial
#

@graceful cradle yo do you have chat?

graceful cradle
#

No, it's not available in my region 💀💀💀

pearl sundial
#

lol

#

@graceful cradle new update

#

roblox sucks tbh

#

@graceful cradle but is the admin abuse good?

#

@graceful cradle btw some planets you cant buy cause i havent made the tools for them yet

true radishBOT
#

studio** You are now Level 8! **studio

graceful cradle
#

Some planets like Trappist are broken

pearl sundial
#

but the tools stay well?

graceful cradle
#

It's a fun game
But it still lacks something...

pearl sundial
#

and dont get deleted

graceful cradle
#

Yep

pearl sundial
#

and a speedcoil shop

#

to catch the planets before other people

#

also maybe freeze items

graceful cradle
#

Also why don't you add events?

#

Like instead of planets 30% of the time cars and trucks will come down and will kill you

#

Kinda like grow a garden

#

Like every 1 hour something random will happen

#

Also the game is really fun too!

pearl sundial
#

Yes ill do stuff like that

#

Rn i have the core gameplay

pearl sundial
sour plaza
# pearl sundial This is the purchasing script for my game: local ServerStorage = game:GetServic...

local ServerStorage = game:GetService("ServerStorage")
local Tool = ServerStorage.Tools:FindFirstChild("FullMutatedSolarEclipse")

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
local leaderstats = player:FindFirstChild("leaderstats")
local Cash = leaderstats and leaderstats:FindFirstChild("Orbs")

if Cash and Cash.Value >= 20000 then
    Cash.Value -= 20000

    local backpack = player:WaitForChild("Backpack")
    local starterGear = player:WaitForChild("StarterGear")

    local toolClone = Tool:Clone()
    toolClone.Parent = backpack

    local toolClone2 = Tool:Clone()
    toolClone2.Parent = starterGear

    game.Workspace.Sounds.POP:Play()
    script.Parent:Destroy()
end

end)
fixed it

pearl sundial
#

@graceful cradle is my game organized good?

graceful cradle
pearl sundial
#

i realized i had to make two tool folders cause the other one doesnt work with local scripts

#

and now its kind of unconsistant but i cant move everything

#

cause i would have to change a lot of scripts

#

if change names n stuff

#

prob just my ocd tho

#

since no regular player can even see this

#

maybe someday im going to make this even more consistant and organized

pearl sundial
#

@graceful cradle hey dude do you know how i would make gui alerts for when something happens in game

#

in this context when a good planet spawns it would say something like " a secret has spawned"

true radishBOT
#

studio** You are now Level 7! **studio

graceful cradle
#

Basically I make a remote event

#

The server will go through all the players in the game and fire the event for each player

#

And it'll also pass a string value

#

That value can be set to "planet John wick has appeared, get it before it's too late!"

#

Each client will have a textLabel gui

#

With a local script that .OnServerEvent

#

Will basically receive the string and show it for the player for like 5 seconds or something

#

That's it

pearl sundial
#

@graceful cradle like this?

#

this is just a test version tho

#

then ill just connect this to the gui right?

graceful cradle
#

Ye

graceful cradle
pearl sundial
#

so i wasnt sure if this is correct

graceful cradle
#

🐟

pearl sundial
#

local Part = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Event = RS.WaitForChild("SpawnAlert")

Part.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Event:FireAllClients()
end
end)

local Text = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("SpawnAlert")
Event:OnClientEvent()
Text.Text = "Hello"

@graceful cradle Why doesnt this work?

graceful cradle
#

Found it...

#

Wait a bit tho...

#

@pearl sundial here it is...

local Part = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Event = RS.WaitForChild("SpawnAlert")

local msg = "hello world!"

Part.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
Event:FireAllClients(msg)
end
end)
-- local script 
local Text = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("SpawnAlert")
Event:OnClientEvent(function(msg)
    Text.Text = msg
    task.wait(5)
    Text.Text = " "
end)
#

I feel like a Pro-Programmer

pearl sundial
#

Oh, why is this simple thing so complicated lol

pearl sundial
#

local RS = game:GetService("ReplicatedStorage")
local Planet = RS.WaitForChild("Planets").WaitForChild("SunGiver")
local Event = RS.WaitForChild("SpawnAlert")

local msg = "A (Godly) Sun has Spawned!"

if Planet.Parent == game.Workspace then
Event:FireAllClients(msg)
end

local Text = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("SpawnAlert")
Event:OnClientEvent(function(msg)
Text.Visible = true
Text.Text = msg
task.wait(5)
Text.Text = " "
end)

@graceful cradle yo dude i edited the scripts a little but it doesnt work

graceful cradle
#

Lemme see...

#
local Planet = RS.WaitForChild("Planets").WaitForChild("SunGiver")
local Event = RS.WaitForChild("SpawnAlert")

local msg = "A (Godly) Sun has Spawned!"

while true do
    task.wait(0.5)
    if Planet.Parent == game.Workspace then
        Event:FireAllClients(msg)
        script:Destroy()
    end
end

``` @pearl sundial
pearl sundial
#

@graceful cradle it doesnt work

#

do i have the set up wrong?

#

do i need anything else besides the remotevent and these 2 scripts

graceful cradle