#why my script doesnt error nor works
1 messages · Page 1 of 1 (latest)
why my script says Workspace.#########.dAddITEM:16: attempt to index nil with 'Button1Up'
HOW tf do i do that
Copy +V
wait(.25)
local plr = game.Players:FindFirstChild(script.Parent.Name)
local mouse = plr:GetMouse()
local tool = game.ReplicatedStorage.Boulder
local cooldown = 10
local coolingDown = false
local explodesIn = 7
local char
local mouseCF
script.Parent.MouseInfoRE.OnServerEvent:Connect(function(plr, mouseHit)
mouseCF = mouseHit
end)
mouse.Button1Up:Connect(function()
if coolingDown then return end
coolingDown = true
wait(0.1)
local clone = tool:Clone()
local bv = Instance.new("BodyVelocity")
bv.Velocity = mouseCF.LookVector * 200
bv.Parent = clone
clone.Parent = workspace
clone.CanCollide = true
local explodeCoro = coroutine.wrap(function()
local code = script.Dmg:Clone()
code.Parent = clone
tool.Grunt2:Play()
code.Enabled = true
wait(explodesIn)
clone:Destroy()
end)
explodeCoro()
wait(0.1)
bv:Destroy()
wait(cooldown - 0.2)
coolingDown = false
end)
wait(.25)
local plr = game.Players:FindFirstChild(script.Parent.Name)
local mouse = plr:GetMouse()
local tool = game.ReplicatedStorage.Boulder
local cooldown = 10
local coolingDown = false
local explodesIn = 7
local char
local mouseCF
script.Parent.MouseInfoRE.OnServerEvent:Connect(function(plr, mouseHit)
mouseCF = mouseHit
end)
mouse.Button1Up:Connect(function()
if coolingDown then return end
coolingDown = true
wait(0.1)
local clone = tool:Clone()
local bv = Instance.new("BodyVelocity")
bv.Velocity = mouseCF.LookVector * 200
bv.Parent = clone
clone.Parent = workspace
clone.CanCollide = true
local explodeCoro = coroutine.wrap(function()
local code = script.Dmg:Clone()
code.Parent = clone
tool.Grunt2:Play()
code.Enabled = true
wait(explodesIn)
clone:Destroy()
end)
explodeCoro()
wait(0.1)
bv:Destroy()
wait(cooldown - 0.2)
coolingDown = false
end)
put 3 ` above & below the message to send it in script format
whats button1up
yall i rhink rthats the solution
let me try
nvm it errored
stfu
there is an local that sends and remote
also
hm
@wet pier it errored
later
no local tool?
wdym
no local player?
make the serverside script only the bowler
then use client
to call it
Ez
ur using local script things in server side
like Getmouse()
and mousehit is local too
bro mised one leter
thats the same code bruh
why yall making it so hard
the problem is
he is getting mouse of the players name
not the actual player
and it doesnt make sense if u use script.parent when its inside startercharacter
cuz u will only return the character and not the actual player
if u want to get the player from the character do game.Players:GetPlayerFromCharacter(script.Parent)
but when its not inside startcharacter do game.Players.LocalPlayer
also
you cant access the mouse from server
only client
now that i caught your attention
why my script doesnt error nor works
o
\
you can change it to this
local players = game:GetService("Players")
local plr = players.LocalPlayer
local hrp = script.Parent
while true do
task.wait(0.01)
local distance = (plr.Character.HumanoidRootPart.CFrame.Position - hrp.CFrame.Position)
local blname;
if distance.Magnitude < 22.5 then
blname = "Phase One"
elseif distance.Magnitude < 20 then
blname = "Phase Two"
elseif distance.Magnitude < 17.5 then
blname = "Phase Three"
elseif distance.Magnitude < 15 then
blname = "Phase Four"
elseif distance.Magnitude < 12.5 then
blname = "Phase Five"
elseif distance.Magnitude < 10 then
blname = "Phase Six"
elseif distance.Magnitude < 7.5 then
blname = "Phase Seven"
elseif distance.Magnitude < 5 then
blname = "Phase Eight"
end
if plr.PlayerGui[blname] then
plr.PlayerGui["Phase One"]:Destroy()
else
local block = Instance.new("Message", plr.PlayerGui)
block.Text = " "
block.Name = blname
end
end
itll be way shorter
tables are a thing
why make script so long for no reason
idk
why it didnt work
oh wait
you have to change it from plr.Character.HumanoidRootPart.Position to plr.Character.HumanoidRootPart.CFrame.Position
and hrp.Position to hrp.CFrame.Position
still doenst work
local players = game:GetService("Players")
local plr = players.LocalPlayer
local hrp = script.Parent
while true do
task.wait(0.01)
local distance = (plr.Character.HumanoidRootPart.Position - hrp.Position)
local blname;
if distance.Magnitude < 22.5 then
blname = "Phase One"
elseif distance.Magnitude < 20 then
blname = "Phase Two"
elseif distance.Magnitude < 17.5 then
blname = "Phase Three"
elseif distance.Magnitude < 15 then
blname = "Phase Four"
elseif distance.Magnitude < 12.5 then
blname = "Phase Five"
elseif distance.Magnitude < 10 then
blname = "Phase Six"
elseif distance.Magnitude < 7.5 then
blname = "Phase Seven"
elseif distance.Magnitude < 5 then
blname = "Phase Eight"
end
if plr.PlayerGui[blname] then
plr.PlayerGui[blname]:Destroy()
else
local block = Instance.new("Message", plr.PlayerGui)
block.Text = " "
block.Name = blname
end
end
what about this
OH WAIT
nvm
what does the error even say
and at what line
did you bother to check the post title?
uh
when the player gets at an certain distance, (for example the fartest distance is one) s when the player gets contant at an distant, a message object will cover the screen, if the player gets too close the messages should stack themselves when a player reaches a distance
at phase eight there should be 8 message instances on the player gui's