-
What do you want to achieve?
Whenever you press e it destroys the model -
What is the issue?
Keep getting this error:
-
What solutions have you tried so far?
I tried switching to a remote function but it came up with the same error. I looked it up too but didn’t find anything useful.
Local Script:
local remoteE = script:WaitForChild("ToLocal")
local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local readyForInput = false
local model = nil
remoteE.OnClientEvent:Connect(function(signal, newModel)
if signal == "touched" then
readyForInput = true
model = newModel
elseif signal == "touchedEnd" then
readyForInput = false
model = nil
end
end)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if readyForInput and model ~= nil then
model.Flower.Destroy.SignalDestroy:FireServer()
end
end
end)
Script to Destroy the part:
script.SignalDestroy.OnServerEvent:Connect(function()
script.Parent.Parent.Parent:Destroy()
end)
Not sure if this is useful but this is the server-side of making the E gui appear:
wait(1)
local range = script.Parent.Parent.Parent.Range
local bill = script.Parent
local playerS = game:GetService("Players")
range.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Name == "RightFoot" then
local char = hit.Parent
local player = playerS:GetPlayerFromCharacter(char)
char.Appear.ToLocal:FireClient(player,"touched", script.Parent.Parent.Parent)
bill.Enabled = true
end
end
end)
range.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Name == "RightFoot" then
local char = hit.Parent
local player = playerS:GetPlayerFromCharacter(char)
char.Appear.ToLocal:FireClient(player,"touchedEnd", script.Parent.Parent.Parent)
bill.Enabled = false
end
end
end)