#Client sided objects
105 messages · Page 1 of 1 (latest)
Create an object on a local script
wdym
so i make a empty local script and put the part in?
or do i add a script for it
like this?
local player = game.Players.LocalPlayer -- Get the local player
local character = player.Character or player.CharacterAdded:Wait() -- Get the player's character
-- Create a new part locally
local part = Instance.new("Part")
part.Size = Vector3.new(4, 1, 2)
part.Position = character.HumanoidRootPart.Position + Vector3.new(5, 0, 0) -- Place it near the player
part.Anchored = true -- Prevent it from falling
part.Parent = game.Workspace -- Parent it to the Workspace, but only the local player will see it
this is correct
so i put the local script inside the part?
no you put this into starterplayerscripts
So i make a local script in starterplayerscripts and add this?
i see that it spawns a part next to the player
but how do i make it like that for already existing parts
you cant really do that
** You are now Level 8! **
I guess its possible to move it to replicated storage and just parent it to workspace in a localscript
cause i made a part like this that explodes when you touch it
but it has to be local
i mean just make the explosion client sided no?
then just do part:destroy() on the client?
idk how
erm anchored?
it's not going to let the player move
unanchor it
remove collision
i know
alr
how do i make the explosion client sided?
you want to make it using the explosion instance?
i have everything i want to make a part that already exists a local part
but also the explosion
local part =game.ReplicatedStorage.Part
part.Parent = game.Workspace
local function explode()
--script
part:Destroy()
end
part.Touched:Connect(explode)
local explosion_Radius = 5
local function createExplosion()
local explosion = Instance.new("Explosion")
explosion.Position = part.Position
explosion.BlastRadius = explosion_Radius
explosion.Parent = part
end
local function onTouch(hit)
-- Check if the touched part belongs to a player
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
-- If it is a player, kick them
player:Kick("You will suffer the consequences")
end
end
part.Touched:Connect(function(hit)
-- Create the explosion
createExplosion()
-- Handle the player kick logic
onTouch(hit)
end) ```
here is the code
ok
alr and the explosion is not working?
well the script is not a local script?
** You are now Level 2! **
shut up mee6
nobody loves u
nft ahh scam
anyways back to the topic
so i just change it to a local script and its client sided?
then put it in a clientscript omfg
localscript u mean
yea
put the same code in a localscript then?
now it doenst work
do you get a error in the output?
no
is your script.Parent (part) in the workspace?
yea
localscripts are not permitted to run in the workspace
put it in starterplayerscripts
then
replace part = script.Parent with part = workspace.whateveryourpartnameis
now is it working?
im checking
local part = game.Workspace:WaitForChild("Part")
Nope
hold on ill fix u r script
opening it in roblox studio
..
kicking a player from localscript?
why do u want it to be local when you're kicking players
i didnt even see that
also it should give you a erorr now
cause the explosion ruins some of the other stuff
ahem ahem
put this in your localscript
local radius = 5
local replicatedStorage = game:GetService("ReplicatedStorage")
local remote = replicatedStorage:WaitForChild("ConsequenceRemote")
part.Touched:Connect(function(basepart)
if basepart.Parent:IsA("Model") and basepart.Parent:FindFirstChild("HumanoidRootPart") and basepart.Parent == game.Players.LocalPlayer.Character then
remote:FireServer()
end
end)```
but its not done yet
create a remoteevent in replicatedstorage
name it consequenceremote
capitalized
so its
ConsequenceRemote
then put this in a server side script (normal script) in serverscriptservice
replicatedStorage.ConsequenceRemote.OnServerEvent:Connect(function(plr)
plr:Kick('blah blah')
end)```
i change the local part = workspace.(''Part'') name of the part?
yes
** You are now Level 3! **
ok
mee6 shut the f up