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

Can someone help with my CAS script?

This is in a local script in a tool. It uses context action service to call a function when you press R, it clones a part from server storage and plays an animation and it doesn't work at all. The output says something is wrong with line 19.

Edit:Fixed errors and it still won't work.

--Normal variable setup
local player = game.Players.LocalPlayer
local char = player.Character
local debounce = false

--Setting up the animation 
local animation = Instance.new("Animation")
animation.Parent = script.Parent
animation.AnimationId = "http://www.roblox.com/Asset?ID=21488069"
local animTrack = char.Humanoid:LoadAnimation(animation)
--Context Action Service
local CAS = game:GetService("ContextActionService")

--Actual function I want to happen
function firewall()
if debounce then return end
local CF = game.ServerStorage.Wall:Clone()
CF.Parent = script.Parent
CF.MainPart.Position = char.Torso.Position + Vector3.new(5,0,0)
CF.MainPart.Rotation = char.Torso.Rotation
animTrack:Play()
debounce = true
wait(5)
debounce = false
end


script.Parent.Equipped:connect(function()
CAS:BindActionToInputTypes("wall", firewall, false, "r") 
end)

script.Parent.Unequipped:connect(function()
CAS:UnbindAction("wall")
end)

1 answer

✓ Accepted answer

LocalScripts don't have access to anything in ServerStorage (clients don't get copies of things there -- this means when players connect they don't have to load these things, which can speed up joining).

Use ReplicatedStorage for things that LocalScripts need to have access to.

8 comments

0

Will replicatedstorage have any adverse effects like starting scripts in the model?

0

Nope. It's exactly the same as ServerStorage, it just copies to clients so that LocalScripts can use models inside of it.

0

It still doesn't work and I put it in replicated storage.

0

And changed the script.

0

Is there an error? Have you done debugging? This definitely solve the only error you told us about. I can't help you if you can't help yourself

0

I've been debugging for a while. Now there are no errors but no output either so I don't know what to fix.

0

If you have been debugging, you would have gotten output -- you should be figuring out what is happening. Debuggin is NOT staring at code and just thinking. It's actually performing experiments.

0

So how should I debug this? What can I test to make this work?

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