Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

FE Handcuffs line 11 is breaking it don't know why?


--NOT MINE

local Player = game.Players.LocalPlayer
local Chr = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
local Tool = script.Parent
local Mode
local Torso
local Using = false
local PTorso
local RemoteEvent = script.Parent.RemoteEvent --- Problem here Any Idea

if Chr:FindFirstChild'UpperTorso' then
	PTorso = Chr.UpperTorso
else 
	PTorso = Chr.Torso
end

Tool.Activated:Connect(function()
	if not Using then
		if Mouse.Target then
			RemoteEvent:FireServer('Cuff', Mouse.Target)
		end
	else 
		Using = false
		RemoteEvent:FireServer('UnCuff')
	end
end)

RemoteEvent.OnClientEvent:Connect(function( one )
	if one == 'Use' then
		Using = true
	end
end)

1 comment

0

what's the error

2 answers

Try to make it wait for child, such as this

local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")

It seems you have a RemoteEvent inside the client where the server can not access. The best place to put RemoteEvents is in ReplicatedStorage as it is shared between the server and the client. I'm assuming that code is in a LocalScript somewhere on the client where it will actually run, i.e not ReplicatedStorage or Workspace. So you need to put your event in ReplicatedStorage and change your event variable to this:

local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent") 

Accept if this helped

1 comment

0

Not working saying it not clicking, Werid,

This discussion is preserved as it was. New answers, comments, and votes are closed.