Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why did this script doesnt work with click detector when it doesnt have any error?

Asked by 6 years ago

It should do when it is activated spawn a object called soda,finding in the workspace a store with the username , and do a value change on Cash but when it is in game It doesnt do anything. I Tried to add it print to see if it atleast write want soda but dont! what can be the problem?

local price = 45
local Soda = game:GetService('ServerStorage').SodaDispenser
local Owner = script.Parent.Parent.Parent.CurrentOwner.Value
Clickdetector = script.Parent.ClickDetector

script.Parent.ClickDetector.MouseClick:connect(function(player)
    if player:FindFirstChild("leaderstats") and Owner.Name == player.Name then
                print(player.Name..' has clicked the button.')
        local clone = Soda:Clone()
        clone.Parent = game.Workspace
        clone.Position = player['Character']['HumanoidRootPart'].Position+Vector3.new(0, 1, 0)
        Clickdetector.Parent.Parent.Parent["Buy a soda dispenser by 45 coins!"].Name = "Done"
        wait(1)
        Clickdetector.Parent.Parent.Parent.Done:Destroy()
        Clickdetector.Parent.Script:Destroy()
        wait(1)
    end
end)

0
Is this in a server script? Gey4Jesus69 2705 — 6y
0
no in the model HillsMaster 34 — 6y
0
in a part called Head so a message calling the price can be seen HillsMaster 34 — 6y

Answer this question