it doesnt work, it is supposed to give ten cash but,
r = game:service("RunService")
shaft = script.Parent
position = shaft.Position
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Cash")
if (score~=nil) then
if (score.Value >=amnt) then
score.Value = score.Value + 10
end
end
end
end
end
local creator = script.Parent:findFirstChild("creator")
if (creator~=nil) then
local thisplr = game.Players:findFirstChild(creator.Value)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Cash")
if (score~=nil) then
if (score.Value >=amnt) then
score.Value = score.Value - 10
end
end
end
end
end
wait(.1)
shaft:remove()
end
function fly()
direction = shaft.CFrame.lookVector
position = position + 5*direction
error = position - shaft.Position
shaft.Velocity = 15*error
end
t, s = r.Stepped:wait()
d = t + 5.0 - s
shaft.Touched:connect(onTouched)
while t < d do
fly()
t = r.Stepped:wait()
end
shaft:remove()
any help?
|