The scripts works in test mode, but didn't work after I start server. The script work when I reset my character. I'm trying to create pink 'fireball'
In the Player1 Roblox studio output it says this
16:51:07.751 - Players.Player1.Backpack.Massive Pinkball.LocalScript:5: attempt to index global 'char' (a nil value)
16:51:07.752 - Stack Begin
16:51:07.753 - Script 'Players.Player1.Backpack.Massive Pinkball.LocalScript', Line 5
16:51:07.754 - Stack End
This is the local script
local Tool = script.Parent
play = game.Players.LocalPlayer
mouse = play:GetMouse()
char = play.Character
hum = char.Humanoid
local en = true
Tool.Activated:connect(function()
if not en then return end
en = false
Tool.RemoteEvent:FireServer(mouse.Hit)
wait(0.5)
en = true
end)
and this is the server script.
local Tool = script.Parent
play = Tool.Parent.Parent
mouse = play:GetMouse()
char = play.Character
hum = char.Humanoid
root = char.HumanoidRootPart
local en = true
Tool.RemoteEvent.OnServerEvent:connect(function(play,mousehit)
local a = hum:LoadAnimation(Tool.Throw)
a:Play()
root.CFrame = CFrame.new(root.Position,root.Position + Vector3.new(mousehit.lookVector.x,0,mousehit.lookVector.z))
wait(0.7)
local pinkball = Tool.Handle:clone()
pinkball.CFrame = Tool.Handle.CFrame
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1e8,1e8,1e8)
bv.Velocity = mousehit.lookVector * 50
bv.Parent = pinkball
pinkball.CanCollide = false
pinkball.Parent = game.Workspace
game.Debris:AddItem(pinkball,4)
local ten = true
pinkball.Touched:connect(function(hit)
if not ten then return end
ten = false
local ehum = hit.Parent:findFirstChild("Humanoid")or hit.Parent.Parent:findFirstChild("Humanoid")
if ehum and ehum ~= hum then
ehum:TakeDamage(10)
elseif hit.Anchored == true and hit.CanCollide == true then
for i=1,10 do
local part = pinkball:clone()
part.Size = Vector3.new(0.5,0.5,0.5)
part.CFrame = pinkball.CFrame
part.BodyVelocity.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
part.Parent = game.Workspace
game.Debris:AddItem(part,1)
end
end
wait()
ten = true
end)
end)
Thank you

1 comment
Thanks this works